﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.ComponentModel;


namespace postSale.Controls
{
    public class gridMaintenanceDetailSeries : common.controls.baseDataGridView 
    {
        public gridMaintenanceDetailSeries()
        {
            this.myAutoFitColumn = ColumnNames.itemSeri.ToString();
            this.AutoArrange();
        }
        public enum ColumnNames {itemSeri};
        public int myParentId = -1;
      
        public override void Init(BindingSource dataSource)
        {
            base.Init(dataSource);

            data.postSaleDS.maintenanceDetailSeriesDataTable detailTbl = (data.postSaleDS.maintenanceDetailSeriesDataTable)dataSource.DataSource;
            
            // 
            // itemSeri
            // 
            common.controls.DataGridViewTextBoxColumnExt itemSeri = new common.controls.DataGridViewTextBoxColumnExt();
            itemSeri.DataPropertyName = detailTbl.seriColumn.ColumnName;
            itemSeri.HeaderText = "Sê ri";
            itemSeri.Name = ColumnNames.itemSeri.ToString();
            itemSeri.Width = 90;
            itemSeri.Uppercase = true;


            // 
            // myDetailGrid
            // 
            this.Visible = true;
            this.DataSource = dataSource;

            this.ReadOnly = false;
            this.ScrollBars = ScrollBars.Vertical;
            this.AutoGenerateColumns = false;
            this.Columns.Clear();
            this.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { itemSeri });
            this.myAutoFitColumn = ColumnNames.itemSeri.ToString();
            this.DisbaleReadOnlyColumns();

        }
        protected override void OnDefaultValuesNeeded(DataGridViewRowEventArgs e)
        {
            base.OnDefaultValuesNeeded(e);
            if (e == null) return;
            if (myDataSource.Current != null)
            {
                data.postSaleDS.maintenanceDetailSeriesRow row = (data.postSaleDS.maintenanceDetailSeriesRow)((DataRowView)myDataSource.Current).Row;
                DataAccess.DataLibs.InitData(row);
                row.parentId = this.myParentId;
            }
        }
    }
}
